package com.qkm.xinguan.controller;

import com.qkm.xinguan.domain.transform.dto.NoticeDTO;
import com.qkm.xinguan.domain.transform.form.NoticeSearchForm;
import com.qkm.xinguan.domain.transform.form.UserSearchForm;
import com.qkm.xinguan.response.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author zfj
 * @date 2021/11/22 -21:09
 */
@RequestMapping("/system/notice")
@Api(value = "公告管理模块", tags = "公告管理接口")
public interface INoticeController {

	@GetMapping("/{id}")
	@PreAuthorize("hasAuthority('notice:queryOne')")
	@ApiOperation(value = "获取单个公告", notes = "根据公告id查询公告信息")
	Result getOneById(@PathVariable("id") Long id);

	@GetMapping("/customer/list")
	@ApiOperation(value = "前端分页获取公告列表信息", notes = "分页")
	Result getNoticePage(@RequestParam(value = "page", defaultValue = "1") Integer page,
	                         @RequestParam(value = "size", defaultValue = "5") Integer size);

	@GetMapping("/list")
	@PreAuthorize("hasAuthority('notice:query')")
	@ApiOperation(value = "分页获取公告列表信息", notes = "分页")
	Result getNoticeListPage(@RequestParam(value = "page", defaultValue = "1") Integer page,
	                        @RequestParam(value = "size", defaultValue = "5") Integer size);

	@PostMapping("/search")
	@PreAuthorize("hasAuthority('notice:query')")
	@ApiOperation(value = "查询公告列表信息", notes = "分页查询")
	Result searchNoticeListPage(@RequestBody NoticeSearchForm noticeSearchForm, @RequestParam(value = "page", defaultValue = "1") Integer page,
	                            @RequestParam(value = "size", defaultValue = "5") Integer size);

	@PostMapping("/add")
	@PreAuthorize("hasAuthority('notice:add')")
	@ApiOperation(value = "添加公告", notes = "公告添加")
	Result addNotice(@RequestBody @Validated NoticeDTO noticeDTO, BindingResult result);

	@PutMapping("/edit/{id}")
	@PreAuthorize("hasAuthority('notice:update')")
	@ApiOperation(value = "编辑公告", notes = "公告信息修改")
	Result editNotice(@RequestBody @Validated NoticeDTO noticeDTO, @PathVariable("id") Long id, BindingResult result);

	@DeleteMapping("/delete/{id}")
	@PreAuthorize("hasAuthority('notice:delete')")
	@ApiOperation(value = "删除公告", notes = "公告信息删除")
	Result deleteNotice(@PathVariable("id") Long id);
}
